from http.client import responses

import requests
from requests.auth import HTTPBasicAuth

# url = "http://127.0.0.1:8000/admin/"
#
# response = requests.get(url)
#
# print(response.text)
# print(response.status_code)

# url = "http://127.0.0.1:8000/admin/"
# response = requests.get(url,allow_redirects=False)
# print(response.status_code)
# print(response.headers.get("Location"))
#
# location = response.headers.get("Location")
# location = f"http://127.0.0.1:8000/admin/{location}"
# response = requests.get(location)
# print(response.status_code)



url = "http://127.0.0.1:8000/admin/"
headers = {
    "User-Agent": "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/000000000 Safari/537.36 Edg/000000000",
    # 携带cookie
    # "Cookie": "sessionid=pbknnyktmpyok2d4kpcm9z34d3h542s4"

}
cookies = {
    "sessionid": "sessionid=pbknnyktmpyok2d4kpcm9z34d3h542s4"
}
response = requests.get(url, headers=headers,cookies= cookies)
print(response.text)
print(response.status_code)






# url = "http://127.0.0.1:8000/admin/"
# response = requests.get(url,auth=HTTPBasicAuth("admin","123456"))
# print(response.text)
# print(response.status_code)



